<template>
  <div class="interview">
    <el-form ref="formData" :model="formData" label-width="110px">
      <h2
        style="
          text-align: center;
          line-height: 60px;
          font-size: 24px;
          font-weight: 600;
          background-color: #8b0013;
          color: #fff;
          margin-bottom: 20px;
        "
      >
        北京大学成都前沿交叉生物技术研究院应聘登记表
      </h2>
      <el-row>
        <el-col :span="8">
          <el-form-item required label="姓名">
            <el-input v-model="formData.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="性别">
            <!-- <el-input v-model="formData.gender"></el-input> -->
            <el-select v-model="formData.gender" placeholder="请选择">
              <el-option
                v-for="it in selectData.sex"
                :key="it.value"
                :label="it.label"
                :value="it.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="出生年月日">
            <el-date-picker
              class="dataDiv"
              v-model="formData.dateofbirth"
              type="date"
              placeholder="选择日期"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item required label="民族">
            <el-select v-model="formData.nation" placeholder="请选择">
              <el-option
                v-for="it in selectData.MinZu"
                :key="it.value"
                :label="it.label"
                :value="it.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="籍贯">
            <el-input v-model="formData.nativeplace"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="年龄">
            <el-input v-model="formData.age"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item required label="婚姻状况">
            <el-select v-model="formData.maritalstatus" placeholder="请选择">
              <el-option
                v-for="it in selectData.HunYinZhuangKuang"
                :key="it.value"
                :label="it.label"
                :value="it.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="政治面貌">
            <el-select v-model="formData.politicsstatus" placeholder="请选择">
              <el-option
                v-for="it in selectData.ZhengZhiMianMao"
                :key="it.value"
                :label="it.label"
                :value="it.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="联系电话">
            <el-input v-model="formData.phone"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item required label="身份证号">
            <el-input v-model="formData.number"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item required :span="12" label="联系地址">
            <el-input v-model="formData.contactaddress"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item required label="电子邮箱">
            <el-input v-model="formData.email"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item required :span="12" label="兴趣爱好">
            <el-input v-model="formData.hobby"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item required label="专业技术职称">
            <el-input v-model="formData.majorname"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item required :span="12" label="职业资格">
            <el-input v-model="formData.qualification"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="margin-top: 5px">
        <div class="margin10">
          <span @click="addItem('education')" class="addBtn"> 新建 </span>
        </div>
        <p class="header">
          <span class="title">教育经历</span>
        </p>
        <div class="content">
          <div class="body">
            <p class="head">
              <span style="min-width: 300px">起止年月</span><span>毕业学校(从大学写起)</span
              ><span>院系及专业</span><span>学位</span><span>是否统招</span
              ><span class="operate">操作</span>
            </p>
            <div
              class="item"
              v-for="(item, index) in educationalList"
              :key="index + 'education'"
            >
              <div>
                <el-date-picker
                  v-model="item.period"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.graduation"
                ></el-input>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.major"
                ></el-input>
              </div>
              <div>
                <el-select v-model="item.qualification" placeholder="请选择">
                  <el-option
                    v-for="item in selectData.XueWei"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </div>
              <div>
                <el-select v-model="item.isrecruit" placeholder="请选择">
                  <el-option
                    v-for="it in selectData.ShiFuTongZhao"
                    :key="it.value"
                    :label="it.label"
                    :value="it.value"
                  >
                  </el-option>
                </el-select>
              </div>
              <div class="operate">
                <el-button
                  style="
                    background-color: rgb(139, 0, 19);
                    color: #fff;
                    border-color: rgb(139, 0, 19);
                  "
                  @click="deleteItem('education', index)"
                  type="danger"
                  >删除</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </el-row>
      <el-row style="margin-top: 5px">
        <div class="margin10">
          <span @click="addItem('work')" class="addBtn"> 新建 </span>
        </div>
        <p class="header">
          <span class="title">工作经历</span>
        </p>
        <div class="content">
          <div class="body">
            <p class="head">
              <span class="flex4" style="min-width: 300px">起止时间</span
              ><span>工作单位</span><span>所任职务</span><span>离职原因</span
              ><span>主动/被动</span><span>主要业绩</span
              ><span class="operate">操作</span>
            </p>
            <div
              class="item"
              v-for="(item, index) in workExperienceList"
              :key="index"
            >
              <div>
                <el-date-picker
                  v-model="item.period"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.workunit"
                ></el-input>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.post"
                ></el-input>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.dimissioncause"
                ></el-input>
              </div>
              <div>
                <el-select v-model="item.activecause" placeholder="请选择">
                  <el-option
                    v-for="it in selectData.ZhuDongBeiDong"
                    :key="it.value"
                    :label="it.label"
                    :value="it.value"
                  >
                  </el-option>
                </el-select>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.performance"
                ></el-input>
              </div>
              <div class="operate">
                <el-button
                  style="
                    background-color: rgb(139, 0, 19);
                    color: #fff;
                    border-color: rgb(139, 0, 19);
                  "
                  @click="deleteItem('work', index)"
                  type="danger"
                  >删除</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </el-row>
      <el-row style="margin-top: 5px">
        <div class="margin10">
          <span @click="addItem('family')" class="addBtn"> 新建 </span>
        </div>
        <p class="header">
          <span class="title">主要家庭成员</span>
        </p>
        <div class="content">
          <div class="body">
            <p class="head">
              <span>关系</span><span>姓名</span><span>工作单位</span
              ><span>所任职务</span><span>联系电话</span
              ><span class="operate">操作</span>
            </p>
            <div
              class="item"
              v-for="(item, index) in familyMemberList"
              :key="index"
            >
              <div>
                <el-input v-model="item.relation"></el-input>
              </div>
              <div>
                <el-input v-model="item.familymember"></el-input>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.familyworkunit"
                ></el-input>
              </div>
              <div>
                <el-input
                  type="textarea"
                  class="wenBen"
                  v-model="item.familypost"
                ></el-input>
              </div>
              <div>
                <el-input v-model="item.familyphone"></el-input>
              </div>
              <div class="operate">
                <el-button
                  style="
                    background-color: rgb(139, 0, 19);
                    color: #fff;
                    border-color: rgb(139, 0, 19);
                  "
                  @click="deleteItem('family', index)"
                  type="danger"
                  >删除</el-button
                >
              </div>
            </div>
          </div>
        </div>
      </el-row>
      <el-row>
        <p class="header">
          <span class="title">培训经历</span>
        </p>
        <div class="content">
          <el-input type="textarea" :rows="2" v-model="formData.trainingrecord">
          </el-input>
        </div>
      </el-row>
      <el-row>
        <p class="header">
          <span class="title">奖惩情况</span>
        </p>
        <div class="content">
          <el-input type="textarea" :rows="2" v-model="formData.awardpunish">
          </el-input>
        </div>
      </el-row>
      <el-row>
        <p class="header">
          <span class="title">应聘信息与承诺</span>
        </p>
        <el-col :span="4">
          <el-form-item required label="应聘职位">
            <el-input v-model="formData.position"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item required label="应聘渠道">
            <el-select
              style="width: 150px"
              v-model="formData.applicationchannel"
              placeholder="请选择"
            >
              <el-option
                v-for="item in selectData.YingPinQuDao"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <el-input
              :disabled="formData.applicationchannel !== '其他'"
              style="width: 100px"
              v-model="formData.elseposition"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item required label="期望年薪">
            <el-input
              v-model="formData.expectannualpay"
              style="width: 100px"
              placeholder="税前"
            ></el-input>
            万元
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item required label="可到岗日期">
            <el-date-picker
              class="dataDiv"
              v-model="formData.arrivaltime"
              type="date"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24" style="margin-bottom: 20px">
          <span style="line-height: 54px" class="ordinaryfont required"
            >求职意向与动机</span
          >
          <el-input
            style="width: calc(100% - 125px)"
            type="textarea"
            :rows="2"
            v-model="formData.jobintention"
          >
          </el-input>
        </el-col>
        <el-col :span="4" style="margin-bottom: 20px">
          <span
            class="ordinaryfont"
            style="display: inline-block; text-align: center; width: 70%"
            >应聘承诺</span
          >
        </el-col>
        <el-col :span="12" style="margin-bottom: 20px">
          <span class="ordinaryfont required">有无亲属在成都研究院任职：</span>
          <el-select
            style="width: 120px"
            v-model="formData.isclan"
            placeholder="请选择"
          >
            <el-option
              v-for="item in selectData.haveRelatives"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <span class="ordinaryfont">如有，姓名 </span>
          <el-input
            :disabled="formData.isclan == '1' || formData.isclan == ''"
            style="width: 100px"
            v-model="formData.clanname"
          ></el-input>
        </el-col>
        <el-col :span="8" style="margin-bottom: 20px">
          <span class="ordinaryfont">所在部门机构：</span>
          <el-input
            :disabled="formData.isclan == '1' || formData.isclan == ''"
            style="width: calc(100% - 110px)"
            v-model="formData.clanunit"
          ></el-input>
        </el-col>
        <el-col :span="2">
          <span style="visibility: hidden">占位</span>
        </el-col>
        <el-col :span="10">
          <span class="ordinaryfont"
            >本人承诺以上提报内容全部属实，如有不实，本人将全部承担相关不利后果。</span
          >
        </el-col>
        <el-col :span="6">
          <el-form-item required label="应聘人">
            <el-input v-model="formData.promisename"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item required label="应聘日期">
            <el-date-picker
              class="dataDiv"
              v-model="formData.promisetime"
              type="date"
              placeholder="选择日期"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-button
          style="
            margin: 0 auto;
            display: block;
            padding: 16px 35px;
            background-color: rgb(139, 0, 19);
            border-color: rgb(139, 0, 19);
            margin-bottom: 10px;
          "
          :disabled="disabled"
          type="primary"
          @click="submitForm()"
          >提交</el-button
        >
      </el-row>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      formData: {
        name: "", //姓名
        gender: "", //性别
        dateofbirth: "", //出生年月日
        nation: "", //民族
        nativeplace: "", //籍贯
        age: "", //年龄
        maritalstatus: "", //婚姻状况
        politicsstatus: "", //政治面貌
        phone: "", //联系电话
        number: "", //身份证号
        contactaddress: "", //联系地址
        email: "", //邮箱
        hobby: "", //兴趣爱好
        majorname: "", //专业技术职称
        qualification: "", //职业资格

        trainingrecord: "", //培训经历
        awardpunish: "", //奖惩情况
        position: "", //应聘岗位
        applicationchannel: "", //应聘渠道
        elseposition: "", //其他应聘渠道
        expectannualpay: "", //期望年薪
        arrivaltime: "", //到岗日期
        jobintention: "", //求职意向与动机
        isclan: "", //是否有亲属在单位任职
        clanname: "", //亲属姓名
        clanunit: "", //亲属部门
        promisename: "", //应聘人
        promisetime: "", //应聘日期
      },
      educationalList: [], //教育经历
      workExperienceList: [], //工作经历
      familyMemberList: [], //家庭成员
      educational: {
        period: "", //起止年月
        graduation: "", //毕业院校
        major: "", //专业
        qualification: "", //学位
        isrecruit: "", //是否统招
      },
      workExperience: {
        period: "", //起止年月
        workunit: "", //单位名称
        post: "", //职务
        dimissioncause: "", //离职原因
        activecause: "", //是否主动离职
        performance: "", //主要业绩
      },
      familyMember: {
        relation: "", //关系
        familymember: "", //姓名
        familyworkunit: "", //工作单位
        familypost: "", //职务
        familyphone: "", //联系电话
      },
      // selectData: {
      //   ShiFu: {
      //     0: "是",
      //     1: "否",
      //   },
      //   ShiFuTongZhao: {
      //     0: "统招",
      //     1: "非统招",
      //   },
      //   MinZu: {
      //     0: "汉族",
      //     1: "壮族",
      //     2: "回族",
      //     3: "满族",
      //     4: "维吾尔族",
      //     5: "苗族",
      //     6: "彝族",
      //     7: "土家族",
      //     8: "藏族",
      //     9: "蒙古族",
      //     10: "侗族",
      //     11: "布依族",
      //     12: "瑶族",
      //     13: "白族",
      //     14: "朝鲜族",
      //     15: "哈尼族",
      //     16: "黎族",
      //     17: "哈萨克族",
      //     18: "傣族",
      //     19: "畲族",
      //     20: "傈僳族",
      //     21: "东乡族",
      //     22: "仡佬族",
      //     23: "拉祜族",
      //     24: "佤族",
      //     25: "水族",
      //     26: "纳西族",
      //     27: "羌族",
      //     28: "土族",
      //     29: "仫佬族",
      //     30: "锡伯族",
      //     31: "柯尔克孜族",
      //     32: "景颇族",
      //     33: "达斡尔族",
      //     34: "撒拉族",
      //     35: "布朗族",
      //     36: "毛南族",
      //     37: "塔吉克族",
      //     38: "普米族",
      //     39: "阿昌族",
      //     40: "怒族",
      //     41: "鄂温克族",
      //     42: "京族",
      //     43: "基诺族",
      //     44: "德昂族",
      //     45: "保安族",
      //     46: "俄罗斯族",
      //     47: "裕固族",
      //     48: "乌孜别克族",
      //     49: "门巴族",
      //     50: "鄂伦春族",
      //     51: "独龙族",
      //     52: "赫哲族",
      //     53: "高山族",
      //     54: "珞巴族",
      //     55: "塔塔尔族",
      //     56: "其他",
      //   },
      //   HunYinZhuangKuang: {
      //     0: "未婚",
      //     1: "已婚",
      //     2: "离异",
      //     3: "丧偶",
      //   },
      //   YingPinQuDao: {
      //     0: "猎聘",
      //     1: "前程无忧",
      //     2: "Boss直聘",
      //     3: "现场招聘会",
      //     4: "校园招聘",
      //     5: "内部推荐",
      //     8: "其他",
      //   },
      //   ZhuDongBeiDong: {
      //     0: "主动",
      //     1: "被动",
      //   },
      //   MianShiJieGuo: {
      //     0: "面试通过",
      //     1: "面试未通过",
      //     2: "offer发放",
      //     3: "放弃offer",
      //     4: "可以入职",
      //     5: "不予入职",
      //     6: "已入职",
      //     7: "放弃入职",
      //     8: "已发起面试",
      //   },
      //   XueWei: {
      //     0: "学士",
      //     1: "硕士",
      //     2: "博士",
      //     3: "无学位",
      //   },
      //   ZhengZhiMianMao: {
      //     0: "群众",
      //     1: "中共党员",
      //     2: "中共预备党员",
      //     3: "共青团员",
      //     4: "民革党员",
      //     5: "民盟盟员",
      //     6: "民建会员",
      //     7: "民进会员",
      //     8: "农工党党员",
      //     9: "致公党党员",
      //     10: "九三学社社员",
      //     11: "台盟盟员",
      //     12: "无党派人士",
      //   },
      // },
      selectData: {}, //下拉数据
      disabled: false, //是否可以点击
    };
  },
  mounted() {
    // 初始时设置一条教育经历
    this.educationalList.push(this.educational);
    this.workExperienceList.push(this.workExperience);
    this.familyMemberList.push(this.familyMember);
    this.getSelectData();
  },
  watch: {
    "formData.dateofbirth": {
      handler(newVal, oldVal) {
        console.log("newVal", newVal);
        var newAge = this.calculateAge(newVal);
        this.formData.age = newAge;
        this.formData.promisetime = newVal;
      },
      deep: true,
    },
    "formData.name": {
      handler(newVal, oldVal) {
        console.log("newVal", newVal);
        this.formData.promisename = newVal;
      },
      deep: true,
    },
  },
  methods: {
    // 新建事件
    addItem(parmas) {
      console.log("addItem", parmas);
      if (parmas == "education") {
        this.educationalList.push({
          period: "", //起止年月
          graduation: "", //毕业院校
          major: "", //专业
          qualification: "", //学位
          isrecruit: "", //是否统招
        });
      } else if (parmas == "work") {
        this.workExperienceList.push({
          period: "", //起止年月
          workunit: "", //单位名称
          post: "", //职务
          dimissioncause: "", //离职原因
          activecause: "", //是否主动离职
          performance: "", //主要业绩
        });
      } else {
        this.familyMemberList.push({
          relation: "", //关系
          familymember: "", //姓名
          familyworkunit: "", //工作单位
          familypost: "", //职务
          familyphone: "", //联系电话
        });
      }
    },
    // 删除事件
    deleteItem(parmas, index) {
      if (parmas == "education") {
        if (this.educationalList.length == 1) {
          this.$message.warning("至少保留一条教育经历");
          return;
        }
        this.educationalList.splice(index, 1);
      } else if (parmas == "work") {
        if (this.workExperienceList.length == 1) {
          this.$message.warning("至少保留一条工作经历");
          return;
        }
        this.workExperienceList.splice(index, 1);
      } else {
        if (this.familyMemberList.length == 1) {
          this.$message.warning("至少保留一条家庭成员数据");
          return;
        }
        this.familyMemberList.splice(index, 1);
      }
    },
    // 获取下拉数据
    getSelectData() {
      this.axios({
        method: "get",
        url: "/seeyon/rest/instrumentResource/getInterviewDown",
      })
        .then((res) => {
          console.log("获取下拉数据res :>> ", res);
          if (res.status == 200) {
            let result = res.data;
            let newObject = {};
            Object.keys(result).forEach((key) => {
              newObject[key] = [];
              Object.keys(result[key]).forEach((item) => {
                newObject[key].push({
                  label: result[key][item],
                  value: item,
                });
              });
            });
            newObject.sex = [
              {
                label: "男",
                value: "0",
              },
              {
                label: "女",
                value: "1",
              },
            ];
            newObject.haveRelatives = [
              {
                label: "有",
                value: "0",
              },
              {
                label: "无",
                value: "1",
              },
            ];
            console.log("newObject :>> ", newObject);
            this.selectData = newObject;
          }
        })
        .catch((err) => {
          console.log("err :>> ", err);
        });
    },
    // 提交数据
    submitForm() {
      console.log("提交数据this :>> ", this);
      if (this.formData.name == "") {
        this.$message.error("请输入姓名");
        return;
      }
      if (this.formData.gender == "") {
        this.$message.error("请选择性别");
        return;
      }
      if (this.formData.dateofbirth == "") {
        this.$message.error("请选择出生年月日");
        return;
      }
      if (this.formData.nation == "") {
        this.$message.error("请选择民族");
        return;
      }
      if (this.formData.nativeplace == "") {
        this.$message.error("请填写籍贯");
        return;
      }
      if (this.formData.age == "") {
        this.$message.error("请填写年龄");
        return;
      }
      if (this.formData.maritalstatus == "") {
        this.$message.error("请选择婚姻状况");
        return;
      }
      if (this.formData.politicsstatus == "") {
        this.$message.error("请选择政治面貌");
        return;
      }
      if (this.formData.phone == "") {
        this.$message.error("请填写联系电话");
        return;
      }
      if (this.formData.number == "") {
        this.$message.error("请填写身份证号");
        return;
      }
      if (this.formData.contactaddress == "") {
        this.$message.error("请填写联系地址");
        return;
      }
      if (this.formData.email == "") {
        this.$message.error("请填写电子邮箱");
        return;
      }
      if (this.formData.hobby == "") {
        this.$message.error("请填写兴趣爱好");
        return;
      }
      if (this.formData.majorname == "") {
        this.$message.error("请填写专业技术职称");
        return;
      }
      if (this.formData.qualification == "") {
        this.$message.error("请填写职业资格");
        return;
      }
      if(this.familyMemberList.findIndex(item => item.relation == "") !== -1) {
        this.$message.error("家庭成员关系不能为空");
        return;
      }

      if(this.familyMemberList.findIndex(item => item.familymember == "") !== -1) {
        this.$message.error("家庭成员姓名不能为空");
        return;
      }
      if (this.formData.trainingrecord == "") {
        this.$message.error("请填写培训经历");
        return;
      }
      if (this.formData.awardpunish == "") {
        this.$message.error("请填写奖惩情况");
        return;
      }

      if (this.formData.position == "") {
        this.$message.error("请填写应聘职位");
        return;
      }
      if (this.formData.applicationchannel == "") {
        this.$message.error("请填写应聘渠道");
        return;
      }
      if (this.formData.applicationchannel == "其他" && this.formData.elseposition == "") {
        this.$message.error("请填写其他应聘渠道");
        return;
      }
      if (this.formData.expectannualpay == "") {
        this.$message.error("请填写期望年薪");
        return;
      }
      if (this.formData.arrivaltime == "") {
        this.$message.error("请填写可到岗日期");
        return;
      }
      if (this.formData.jobintention == "") {
        this.$message.error("请填写求职意向与动机");
        return;
      }
      if (this.formData.isclan == "0" && this.formData.clanname == "") {
        this.$message.error("请填写亲属名字");
        return;
      }
      if (this.formData.isclan == "0" && this.formData.clanunit == "") {
        this.$message.error("请填写亲属所在部门机构");
        return;
      }
      if (this.formData.promisename == "") {
        this.$message.error("请填写承诺人");
        return;
      }
      var result = this.validateIdCardBirthday(
        this.formData.number,
        this.formData.dateofbirth
      );
      if (result == "-1") {
        this.$message.error("身份证无效");
        return;
      }
      if (result == "0") {
        this.$message.error("身份证号与出生日期不匹配");
        return;
      }
      var resultSex = this.validateIdCardGender(
        this.formData.number,
        this.formData.gender == 0 ? "男" : "女"
      );
      if (resultSex == "-1") {
        this.$message.error("身份证无效");
        return;
      }
      if (resultSex == "0") {
        this.$message.error("身份证号和性别不匹配");
        return;
      }
      console.log("resultSex", resultSex);
      var parmas = { ...this.formData };
      parmas.background = this.educationalList;
      parmas.work = this.workExperienceList;
      parmas.family = this.familyMemberList;
      parmas.background.forEach((item, index) => {
        parmas.background[index].educationbegintime = item.period[0];
        parmas.background[index].educationfinishtime = item.period[1];
      });
      parmas.work.forEach((item, index) => {
        parmas.work[index].workbegintime = item.period[0];
        parmas.work[index].workfinishtime = item.period[1];
      });
      console.log("保存数据参数parmas", parmas);
      this.axios({
        method: "post",
        url: "/seeyon/rest/instrumentResource/pushInterviewForm",
        headers: {
          "Content-Type": "application/json",
        },
        data: parmas,
      }).then((res) => {
        console.log("提交数据res :>> ", res);
        if (res.data.code == 200) {
          this.disabled = !this.disabled;
          this.$message.success("提交成功");

          // setTimeout(() => {
          //   this.disabled = !this.disabled;
          // }, 3000);
        }
      });
    },
    // 自动计算年龄
    calculateAge(birthDate) {
      const today = new Date();
      const birthDateObj = new Date(birthDate);

      let age = today.getFullYear() - birthDateObj.getFullYear();
      const monthDifference = today.getMonth() - birthDateObj.getMonth();

      if (
        monthDifference < 0 ||
        (monthDifference === 0 && today.getDate() < birthDateObj.getDate())
      ) {
        age--;
      }
      return age;
    },
    // 计算出生年月与身份证号码是否一致
    validateIdCardBirthday(idCard, inputBirthday) {
      // 1. 校验身份证号码格式
      const idCardRegex = /^\d{17}(\d|X|x)$/; // 18位身份证号
      const idCardRegex15 = /^\d{15}$/; // 15位身份证号

      let birthDate;

      if (idCardRegex.test(idCard)) {
        // 18位身份证号，提取出生日期
        birthDate = idCard.substring(6, 14);
      } else if (idCardRegex15.test(idCard)) {
        // 15位身份证号，提取出生日期并转为18位
        birthDate = "19" + idCard.substring(6, 12); // 在年份前加上'19'，例如'900101' -> '19900101'
      } else {
        return "-1";
      }

      // 2. 格式化输入的出生年月为 yyyyMMdd 格式
      const formattedInputBirthday = inputBirthday.replace(/-/g, "");

      // 3. 校验出生年月是否一致
      if (birthDate === formattedInputBirthday) {
        return "1";
      } else {
        return "0";
      }
    },
    // 计算身份证与性别
    validateIdCardGender(idCard, inputGender) {
      // 1. 校验身份证号码格式（支持18位和15位身份证）
      const idCardRegex18 = /^\d{17}(\d|X|x)$/; // 18位身份证号
      const idCardRegex15 = /^\d{15}$/; // 15位身份证号

      let genderDigit;

      if (idCardRegex18.test(idCard)) {
        // 18位身份证号，提取性别信息
        genderDigit = parseInt(idCard.charAt(16)); // 第17位数字（0开始索引）
      } else if (idCardRegex15.test(idCard)) {
        // 15位身份证号，提取性别信息
        genderDigit = parseInt(idCard.charAt(14)); // 第15位数字（0开始索引）
      } else {
        return "-1";
      }

      // 2. 根据数字判断性别
      const idCardGender = genderDigit % 2 === 0 ? "女" : "男";

      // 3. 校验身份证性别与填写的性别是否一致
      if (idCardGender === inputGender) {
        return "1";
      } else {
        return "0";
      }
    },
  },
};
</script>
<style lang='less' scoped>
.interview {
  margin: 0;
  padding: 0 100px;
  background-color: #f5f5f5;
  .el-form {
    background-color: #fff;
    .el-row {
      padding: 10px;
    }
    .el-select {
      width: 100%;
    }
  }
}
.header {
  border-bottom: 2px solid rgb(139, 0, 19);
  margin-bottom: 10px;
  height: 40px;
  line-height: 40px;
  .title {
    background-color: rgb(139, 0, 19);
    display: inline-block;
    padding: 0 10px;
    line-height: 40px;
    color: #fff;
  }
}
.content {
  .body {
    background-color: #f6f6f6;
    padding: 0 5px 5px;
    .head {
      width: 100%;
      height: 40px;
      line-height: 40px;
      // background-color: #f6f6f6;
      display: flex;
      justify-content: space-between;
      span {
        flex: 2;
        display: inline-block;
        text-align: center;
      }
      .operate {
        flex: 1;
      }
    }
    .item {
      width: 100%;
      height: 40px;
      line-height: 40px;
      display: flex;
      justify-content: space-between;
      padding: 5px 0;
      div {
        flex: 2;
      }
      .operate {
        flex: 1;
        text-align: center;
      }
    }
  }
}
.ordinaryfont {
  text-align: right;
  vertical-align: middle;
  //float: left;
  font-size: 14px;
  color: #606266;
  line-height: 40px;
  padding: 0 12px 0 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.required::before {
  content: "*";
  color: #f56c6c;
  margin-right: 4px;
}
/deep/.el-date-editor--daterange {
  width: 300px;
}
/deep/.el-date-editor--daterange .el-range-input {
  font-size: 12px;
}
.addBtn {
  width: 80px;
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  -webkit-appearance: none;
  text-align: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  outline: 0;
  margin: 0;
  -webkit-transition: 0.1s;
  transition: 0.1s;
  font-weight: 500;
  padding: 12px 15px;
  font-size: 14px;
  border-radius: 4px;
  color: #fff;
  background-color: rgb(139, 0, 19);
  text-align: right;

  position: relative;
}

.addBtn::before {
  content: "+";
  font-size: 24px;
  position: absolute;
  top: 17px;
  left: 14px;
  transform: translateY(-50%);
  color: #fff;
}
.margin10 {
  margin: 10px 0;
}
.dataDiv {
  width: 100%;
}
/deep/.wenBen .el-textarea__inner {
  height: 40px;
  // line-height: 40px;
  margin-top: 2px;
  resize: none;
  // min-height: 0px !important;
}
</style>
<style>
* {
  margin: 0;
  padding: 0;
}
html,
body {
  /* margin: 0;
  padding: 0; */
}
</style>